home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 26 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  105 lines

  1. Path: in1.uu.net!bounce-back
  2. Date: 10 Jan 96 08:21:21 GMT
  3. Approved: fjh@cs.mu.oz.au
  4. Organization: -
  5. Newsgroups: comp.std.c++
  6. X-Original-Date: Tue, 9 Jan 1996 22:22:27 GMT
  7. Message-ID: <199601092222.WAA27727@eiger.pncl.co.uk>
  8. X-Sender: dcb@pncl.co.uk
  9. X-Mailer: Windows Eudora Version 1.4.4
  10. Content-Type: text/plain; charset="us-ascii"
  11. From: dcb@pncl.co.uk (David C Binderman)
  12. Subject: ambiguous or not ?
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBEAgUBMPN3JeEDnX0m9pzZAQE4tQF46EPX7yH0MqYEuO7DLitQjh/sShWjyLBg
  15.     xdQ2aeI5rSHO2JTzOyvBRu3zmoJfF9w=
  16.     =/0ch
  17.  
  18. Hello there,
  19.  
  20. Following on from an outbreak of compiler disagreement,
  21.  
  22. // is this ambiguous or not ?
  23.  
  24. // workaround is to use cast on lhs
  25.  
  26.  
  27.  
  28. #include <iostream.h>
  29.  
  30.  
  31. class S
  32. {
  33.  
  34. public:
  35.     
  36.     S( char ) {
  37.         
  38.         cerr << "S::S char\n";
  39.     
  40.     };
  41.     
  42.     S( unsigned char ) {
  43.         
  44.         cerr << "S::S char\n";
  45.     
  46.     };
  47. };
  48.  
  49.  
  50.  
  51. operator == ( char, const S &)
  52.  
  53. {
  54.     
  55.     cerr << "operator ==\n";
  56.  
  57. };
  58.  
  59.  
  60.  
  61. class R
  62. {
  63.  
  64. public:
  65.     
  66.     enum { a, b, c};
  67.     
  68.     operator int () {
  69.         
  70.         cerr << "R::operator int\n";
  71.     
  72.     };
  73.  
  74. };
  75.  
  76.  
  77.  
  78. int
  79. main()
  80.  
  81. {
  82.     
  83.     R z;
  84.     
  85.     // if ((int) z == R::a)
  86.     // workaround line
  87.     if (z == R::a)
  88.  // ambiguous ?
  89.         ;
  90.  
  91. }
  92.  
  93. my opinion is that the code is ok, and the compilers that think it is
  94. ambiguous are wrong.
  95.  
  96. Your opinion sought
  97.  
  98. Regards
  99. David Binderman MSc BSc    +44 1293 544 364       dcb@pncl.co.uk
  100.       If only everything in life was as reliable as a Toyota
  101. ---
  102. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  103.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  104.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  105.